import request from '@/utils/request'

//管理员创建志愿活动
export const adminCreateVolunteerService = ({
  activityName,
  organization,
  activityLocation,
  linkman,
  contact,
  beginTime,
  endTime,
  recruitNumber,
  recruitmentPositions,
  registrationDeadline,
  eventDescription,
  eventContent,
  eventPhoto,
  enrollmentRestrictions,
  tag
}) =>
  request.post('/web/admin/activity/create', {
    activityName,
    organization,
    activityLocation,
    linkman,
    contact,
    beginTime,
    endTime,
    recruitNumber,
    recruitmentPositions,
    registrationDeadline,
    eventDescription,
    eventContent,
    eventPhoto,
    enrollmentRestrictions,
    tag
  })

//管理员更新活动
export const adminUpdateVolunteerService = ({
  id,
  activityName,
  organization,
  activityLocation,
  linkman,
  contact,
  beginTime,
  endTime,
  recruitNumber,
  recruitmentPositions,
  registrationDeadline,
  eventDescription,
  eventContent,
  eventPhoto,
  tag,
  deleted
}) =>
  request.put('/web/admin/activity/update', {
    id,
    activityName,
    organization,
    activityLocation,
    linkman,
    contact,
    beginTime,
    endTime,
    recruitNumber,
    recruitmentPositions,
    registrationDeadline,
    eventDescription,
    eventContent,
    eventPhoto,
    tag,
    deleted
  })

//分页查询志愿活动
export const adminQueryVolunteerService = ({
  activityName,
  pageNo,
  pageSize
}) => {
  const params = {
    activityName,
    pageNo,
    pageSize
  }
  if (activityName === '') {
    delete params.activityName
  }
  return request.get('/web/admin/activity/activityPage', {
    params: params
  })
}

//根据id查询活动
export const adminQueryVolunteerByIdService = (id) =>
  request.get(`/web/admin/activity/activity/${id}`)

//导出参加该自愿活动的人员名单
export const exportVolunteerService = (id) => {
  return request.get(`/web/admin/activity/export/${id}`, {
    responseType: 'blob' // 确保响应类型是 'blob'，用于下载二进制文件
  })
}
